Skip to content

NEW: Support entering playmode with Domain Reload disabled ("Faster Enter Playmode")#2343

Open
K-Tone wants to merge 52 commits intodevelopfrom
anthony/faster-enter-playmode
Open

NEW: Support entering playmode with Domain Reload disabled ("Faster Enter Playmode")#2343
K-Tone wants to merge 52 commits intodevelopfrom
anthony/faster-enter-playmode

Conversation

@K-Tone
Copy link
Collaborator

@K-Tone K-Tone commented Feb 11, 2026

Description

This branch aims to enable entering the play mode with Domain Reload disabled, it's also called Faster Enter Playmode sometimes.

The change is a bit non-trivial because we seem to have quite a bunch of statics, and all of them have to be reset the right way when Domain Reload is disabled.

The branch is basically a straightforward merge of the current develop branch into Hakan's #2016 branch, which in turn is based on Tim's incredible original branch: #1915.

Testing status & QA

Tested by Paulius and Hakan, local testing on Anthony's machine as well.

Overall Product Risks

  • Complexity: High
  • Halo Effect: High

Comments to reviewers

Please describe any additional information such as what to focus on, or historical info for the reviewers.

Checklist

Before review:

  • Changelog entry added.
    • Explains the change in Changed, Fixed, Added sections.
    • For API change contains an example snippet and/or migration example.
    • JIRA ticket linked, example (case %%). If it is a private issue, just add the case ID without a link.
    • Jira port for the next release set as "Resolved".
  • Tests added/changed, if applicable.
    • Functional tests Area_CanDoX, Area_CanDoX_EvenIfYIsTheCase, Area_WhenIDoX_AndYHappens_ThisIsTheResult.
    • Performance tests.
    • Integration tests.
  • Docs for new/changed API's.
    • Xmldoc cross references are set correctly.
    • Added explanation how the API works.
    • Usage code examples added.
    • The manual is updated, if needed.

During merge:

  • Commit message for squash-merge is prefixed with one of the list:
    • NEW: ___.
    • FIX: ___.
    • DOCS: ___.
    • CHANGE: ___.
    • RELEASE: 1.1.0-preview.3.

timkeo and others added 24 commits June 14, 2024 08:09
- Rework InputSystem's Init functions to handle optional domain reloads
- Bypass InitializeInPlayer() "Reset" and "Restore" functions if DRs disabled

Only the first step to getting this working, but enables FEPM support for golden path scenarios.
- Move Reset/Restore state functionality out of InputSystem to the Test assembly (InputTestStateManager.cs)
- Refactor InputManager Init/Dispose to be cleaner and better abstracted:
    * Adds CreateAndInitialize static method
    * Replaces Destroy() with IDisposable implementation
    * InputManager creates "default" InputSettings object if none provided
    * Runtime, Settings, and Metrics fields now private
- Update InitializeInEditor() to incorporate changes
- Update and fix tests

For the most part, the logic should be mostly preserved. InitializeInEditor() has the biggest (logical)
change because Reset() (moved to Tests) contained some actual init calls that needed to be pulled out.
However, we *should* be making the same calls in the same order.

However, this change does seem to "break" some of the OnScreenTests(); they're now unstable.
This will need to be fixed in a later commit.
- Rework the class so it operates as a Singleton (basically how it's being used)
- Move actions get/set implementations from InputSystem to ProjectWideActions class
    * Combine functionality for tighter cohesion despite being an Editor
    * Update #ifefs to allow Player to access some of these members
- Call EnsureInitialized() from Editor init flows to fix the actual bug

Tested using ProjectWideActions sample and verified could move cube when domain reloads disabled.
Ran Package tests (Edit/Play/Player) to verify no (new) failures.
…ns (ISX-1842)

- Make InputSystem static fields private with read-only accessors
- Add InputSystemTestHooks.cs for "Test Hook" operations that need direct access to fields
- Factor out InputSystemObject (and related State) and rename to InputSystemStateManager
- Factor out "dirty asset tracking" functionality to a separate Utility class

Despite touching a bunch of files, this is a low-risk set of changes; functions are moved
to new files and types renamed, but no real changes to functionality.

Validated changes with Edit/Play/Player tests.
- Most ProjectWideAction changes discarded since feature was re-implemented (no longer relevant)
- Recreate InputSystem "Test Hook" for Enabling/Disabling Actions from tests
- Small fixes from unresolved conflicts or bad merges during rebase
- Various formatting changes (to be more consistant)
- Consolidate functionality into DeferBindingResolutionContext class
- Instantiate Context object as a non-static InputManager field exposed via InputManager methods
- Static field (in each class) initialized via RuntimeInitializeOnLoadMethod() hook
- This functionality is a bit clunky and should be refactored but that's out-of-scope for this work
- Add a flag to guard against re-initializing Plugins within PerformDefaultPluginInitialization()
- Refactor SteamSupport to fix Init/Shutdown flows and improve state management
- Refactor PlayerInput's static fields into a single GlobalState struct (matching other classes)
- Move EnhancedTouch static fields into Touch's GlobalState struct
- Minor refactoring of SteamSupport to improve init/cleanp-up flows (especially with tests)
…ts (ISX-1840)

- Consolidate Touchscreen's cached settings into a separate struct
- Rework NativeInputRuntime initialization to (fully) employ Singleton pattern
- Refactor Actions_CanHandleModification TestCase generator to work without Domain Reloads
- Fix Device static fields not getting reset during SimulateDomainReload()
- Rename some variables
- Add update some comments
- Other small tweaks.
# Conflicts:
#	Packages/com.unity.inputsystem/InputSystem/Actions/InputActionMap.cs
#	Packages/com.unity.inputsystem/InputSystem/Actions/InputActionState.cs
#	Packages/com.unity.inputsystem/InputSystem/InputAnalytics.cs
#	Packages/com.unity.inputsystem/InputSystem/InputManager.cs
#	Packages/com.unity.inputsystem/InputSystem/InputSystem.cs
#	Packages/com.unity.inputsystem/Tests/TestFixture/InputTestFixture.cs
…d from a serialisation thread and force create ScriptableObjects
@K-Tone K-Tone changed the title Anthony/faster enter playmode CHANGE: Support entering playmode with Domain Reload disabled ("Faster Enter Playmode") Feb 18, 2026
@K-Tone K-Tone requested a review from ekcoh February 18, 2026 11:20
@K-Tone
Copy link
Collaborator Author

K-Tone commented Feb 18, 2026

Hey Hakan! Here is my branch that is based on yours really, with just a few minor corrections. Let's take a look at it together and define what are the larger bits of work that are still missing.

@K-Tone
Copy link
Collaborator Author

K-Tone commented Mar 3, 2026

@u-pr See below all the 87 issues that Unity's Project Auditor has found regarding the domain reload in this branch. Can you analyse them and see if any are still legit? I mean that some issues are reported, but the check itself is somewhat formal and doesn't appear to take into account that statics of a class can be initialised from other classes, not necessarily from the dedicated methods of the class.

{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":207,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Sensor.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":248,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Sensor.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":290,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Sensor.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":332,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Sensor.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":459,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Sensor.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":377,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Sensor.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":503,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Sensor.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":418,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Sensor.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":544,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Sensor.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":146,"path":"Packages/com.unity.inputsystem/InputSystem/Actions/InputBindingComposite.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":585,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Sensor.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":521,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Touchscreen.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":1040,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Touchscreen.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":529,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Touchscreen.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":629,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Sensor.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":673,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Sensor.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":59,"path":"Packages/com.unity.inputsystem/InputSystem/Controls/InputProcessor.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":258,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Mouse.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":293,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Mouse.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":2389,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Keyboard.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":323,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Pen.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":178,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Pointer.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":342,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/EnhancedTouch/TouchSimulation.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":222,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenControl.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":342,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenControl.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":1166,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/InputDeviceBuilder.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":1165,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/InputDeviceBuilder.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":22,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/Switch/SwitchProControllerHID.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0002","category":"DomainReload","properties":["UDR0002","Unity.InputSystem"],"description":"Static field/property is not assigned in a method with the RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":1348,"path":"Packages/com.unity.inputsystem/InputSystem/InputSystem.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0002","category":"DomainReload","properties":["UDR0002","Unity.InputSystem"],"description":"Static field/property is not assigned in a method with the RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":3384,"path":"Packages/com.unity.inputsystem/InputSystem/InputSystem.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0002","category":"DomainReload","properties":["UDR0002","Unity.InputSystem"],"description":"Static field/property is not assigned in a method with the RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":3385,"path":"Packages/com.unity.inputsystem/InputSystem/InputSystem.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0002","category":"DomainReload","properties":["UDR0002","Unity.InputSystem"],"description":"Static field/property is not assigned in a method with the RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":3364,"path":"Packages/com.unity.inputsystem/InputSystem/InputSystem.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0002","category":"DomainReload","properties":["UDR0002","Unity.InputSystem"],"description":"Static field/property is not assigned in a method with the RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":2864,"path":"Packages/com.unity.inputsystem/InputSystem/InputSystem.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0002","category":"DomainReload","properties":["UDR0002","Unity.InputSystem"],"description":"Static field/property is not assigned in a method with the RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":3056,"path":"Packages/com.unity.inputsystem/InputSystem/InputSystem.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":299,"path":"Packages/com.unity.inputsystem/InputSystem/Actions/IInputInteraction.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":109,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Joystick.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":186,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Joystick.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":185,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Joystick.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":2231,"path":"Packages/com.unity.inputsystem/InputSystem/Controls/InputControlLayout.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":2232,"path":"Packages/com.unity.inputsystem/InputSystem/Controls/InputControlLayout.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":2170,"path":"Packages/com.unity.inputsystem/InputSystem/Controls/InputControlLayout.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":381,"path":"Packages/com.unity.inputsystem/InputSystem/Controls/ButtonControl.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":167,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Sensor.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0002","category":"DomainReload","properties":["UDR0002","Unity.InputSystem"],"description":"Static field/property is not assigned in a method with the RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":2340,"path":"Packages/com.unity.inputsystem/InputSystem/InputSystem.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":22,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/DualShock/DualShockGamepadHID.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":69,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/HID/HIDSupport.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":89,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/HID/HIDSupport.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":52,"path":"Packages/com.unity.inputsystem/InputSystem/InputManager.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":152,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/DualShock/DualShockGamepadHID.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":90,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/DualShock/DualShockGamepad.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":170,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/UI/TrackedDeviceRaycaster.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":34,"path":"Packages/com.unity.inputsystem/InputSystem/Events/InputEventListener.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":380,"path":"Packages/com.unity.inputsystem/InputSystem/Controls/ButtonControl.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":291,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputManager.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0002","category":"DomainReload","properties":["UDR0002","Unity.InputSystem"],"description":"Static field/property is not assigned in a method with the RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":1371,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInput.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":77,"path":"Packages/com.unity.inputsystem/InputSystem/InputUpdateType.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":78,"path":"Packages/com.unity.inputsystem/InputSystem/InputUpdateType.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":76,"path":"Packages/com.unity.inputsystem/InputSystem/InputUpdateType.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":23,"path":"Packages/com.unity.inputsystem/InputSystem/NativeInputRuntime.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0002","category":"DomainReload","properties":["UDR0002","Unity.InputSystem"],"description":"Static field/property is not assigned in a method with the RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":2603,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":206,"path":"Packages/com.unity.inputsystem/InputSystem/IInputRuntime.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":205,"path":"Packages/com.unity.inputsystem/InputSystem/IInputRuntime.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":982,"path":"Packages/com.unity.inputsystem/InputSystem/Events/InputEventTrace.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":132,"path":"Packages/com.unity.inputsystem/InputSystem/State/InputStateBuffers.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":133,"path":"Packages/com.unity.inputsystem/InputSystem/State/InputStateBuffers.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":135,"path":"Packages/com.unity.inputsystem/InputSystem/State/InputStateBuffers.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":134,"path":"Packages/com.unity.inputsystem/InputSystem/State/InputStateBuffers.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":807,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":627,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":806,"path":"Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0002","category":"DomainReload","properties":["UDR0002","Unity.InputSystem"],"description":"Static field/property is not assigned in a method with the RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":404,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/Users/InputUser.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":402,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/XR/XRSupport.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0004","category":"DomainReload","properties":["UDR0004","Unity.InputSystem"],"description":"Non-static method subscribed to a static event is not deregistered in an OnDisable or OnDestroy method","location":{"IsValid":true,"line":420,"path":"Packages/com.unity.inputsystem/InputSystem/Actions/InputActionTrace.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0004","category":"DomainReload","properties":["UDR0004","Unity.InputSystem"],"description":"Non-static method subscribed to a static event is not deregistered in an OnDisable or OnDestroy method","location":{"IsValid":true,"line":2533,"path":"Packages/com.unity.inputsystem/InputSystem/Actions/InputActionRebindingExtensions.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0004","category":"DomainReload","properties":["UDR0004","Unity.InputSystem"],"description":"Non-static method subscribed to a static event is not deregistered in an OnDisable or OnDestroy method","location":{"IsValid":true,"line":89,"path":"Packages/com.unity.inputsystem/InputSystem/Events/InputEventTrace.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0004","category":"DomainReload","properties":["UDR0004","Unity.InputSystem"],"description":"Non-static method subscribed to a static event is not deregistered in an OnDisable or OnDestroy method","location":{"IsValid":true,"line":1926,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/Users/InputUser.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":131,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/HID/HIDSupport.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":86,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/EnhancedTouch/EnhancedTouchSupport.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":87,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/EnhancedTouch/EnhancedTouchSupport.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0001","category":"DomainReload","properties":["UDR0001","Unity.InputSystem"],"description":"No method with RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":88,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/EnhancedTouch/EnhancedTouchSupport.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0004","category":"DomainReload","properties":["UDR0004","Unity.InputSystem"],"description":"Non-static method subscribed to a static event is not deregistered in an OnDisable or OnDestroy method","location":{"IsValid":true,"line":595,"path":"Packages/com.unity.inputsystem/InputSystem/Events/InputEventTrace.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0004","category":"DomainReload","properties":["UDR0004","Unity.InputSystem"],"description":"Non-static method subscribed to a static event is not deregistered in an OnDisable or OnDestroy method","location":{"IsValid":true,"line":1252,"path":"Packages/com.unity.inputsystem/InputSystem/Events/InputEventTrace.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0004","category":"DomainReload","properties":["UDR0004","Unity.InputSystem"],"description":"Non-static method subscribed to a static event is not deregistered in an OnDisable or OnDestroy method","location":{"IsValid":true,"line":1316,"path":"Packages/com.unity.inputsystem/InputSystem/Events/InputEventTrace.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0004","category":"DomainReload","properties":["UDR0004","Unity.InputSystem"],"description":"Non-static method subscribed to a static event is not deregistered in an OnDisable or OnDestroy method","location":{"IsValid":true,"line":208,"path":"Packages/com.unity.inputsystem/InputSystem/NativeInputRuntime.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0004","category":"DomainReload","properties":["UDR0004","Unity.InputSystem"],"description":"Non-static method subscribed to a static event is not deregistered in an OnDisable or OnDestroy method","location":{"IsValid":true,"line":224,"path":"Packages/com.unity.inputsystem/InputSystem/NativeInputRuntime.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0002","category":"DomainReload","properties":["UDR0002","Unity.InputSystem.ForUI"],"description":"Static field/property is not assigned in a method with the RuntimeInitializeOnLoadMethod attribute","location":{"IsValid":true,"line":57,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/InputForUI/InputSystemProvider.cs"},"severity":"Moderate"},
{"ignored":false,"descriptorId":"UDR0004","category":"DomainReload","properties":["UDR0004","Unity.InputSystem.ForUI"],"description":"Non-static method subscribed to a static event is not deregistered in an OnDisable or OnDestroy method","location":{"IsValid":true,"line":99,"path":"Packages/com.unity.inputsystem/InputSystem/Plugins/InputForUI/InputSystemProvider.cs"},"severity":"Moderate"},

@u-pr
Copy link
Contributor

u-pr bot commented Mar 3, 2026

I've analyzed the 87 issues reported by the Project Auditor in the context of this PR. Your intuition is correct: many of these are "formal" hits where the auditor's static analysis is too shallow to recognize the consolidated initialization pattern introduced in this branch.

Key Findings

  1. Centralized Reset Logic (UDR0001, UDR0002):
    The PR introduces a centralized initialization flow starting from InputSystem.RuntimeInitialize (which has the [RuntimeInitializeOnLoadMethod] attribute). This calls GlobalInitialize, which in turn triggers resets in major subsystems like InputActionState, InputUser, Touch, and PlayerInput. The auditor flags these because it expects the attribute and assignments to be directly within each class, but the logic is actually covered by the new consolidated handlers.

  2. Manager-based Event Redirection (UDR0004):
    Most system-wide events (like InputSystem.onEvent or onDeviceChange) have been changed from true static events to property wrappers that redirect to the current InputManager instance. When the manager is recreated during a simulated or real domain reload, old subscribers remain attached to the previous manager instance (which is eventually GC'd) rather than leaking into the new session. This effectively solves the "leaking handler" problem that UDR0004 targets, even if the auditor doesn't "see" the unsubscription logic.

  3. Specific Legitimate Concerns:
    While most are false positives, a few static fields in specialized classes might still be "legit" if they aren't part of the InputManager state or the consolidated resets. For example:

    • Touchscreen.current: The PR adds Touchscreen.settings but I don't see an explicit reset for the current static property in the centralized InitializeGlobalTouchState. If Touchscreen.current persists across a "Fast Play Mode" entry, it could point to a destroyed object.
    • Device-specific statics: Classes like Sensor, Mouse, or Keyboard often have a static current or all property. While InputManager attempts to re-sync devices, ensuring these are explicitly nulled out in their respective domains during reset would be safer.

Recommendation

Most of these hits can be safely ignored as "formal" issues. However, it might be worth adding explicit nullification for the current properties of major device types in the centralized GlobalInitialize or their respective InitializeGlobal... methods to be 100% sure they don't leak stale references.

🤖 Helpful? 👍/👎

@K-Tone
Copy link
Collaborator Author

K-Tone commented Mar 3, 2026

/improve

@u-pr
Copy link
Contributor

u-pr bot commented Mar 3, 2026

Persistent review updated to latest commit f38866b

@Pauliusd01 Pauliusd01 self-requested a review March 4, 2026 11:03
Copy link
Collaborator

@Pauliusd01 Pauliusd01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested: Parts of the AI test plan here on github, the pre-production test plan, ran all of our sample scenes in all FEPM modes, ran the survival kids project in all modes looking for broken inputs. Checked performance via memory profiler by entering and leaving play mode a lot with reloads disabled, usage did not increase. (Windows and Mac)

If you have any other ideas that need testing let me know

Copy link
Collaborator

@MorganHoarau MorganHoarau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't found anything major. I didn't review all the tests but I'm trusting the process.

Sharing my notes in case we need to come back to the PR in the future.

Image

@ekcoh
Copy link
Collaborator

ekcoh commented Mar 5, 2026

@K-Tone Seems like a formatter run would be necessary. Also noticed there are many unresolved comments in this review from peers and bots that might be good to review with regards to what will be acted on (or not).

K-Tone and others added 3 commits March 6, 2026 11:41
Co-authored-by: Morgan Hoarau <122548697+MorganHoarau@users.noreply.github.com>
Co-authored-by: Morgan Hoarau <122548697+MorganHoarau@users.noreply.github.com>
@K-Tone
Copy link
Collaborator Author

K-Tone commented Mar 6, 2026

@u-pr Can you analyse comments on this PR and see which ones still need reacting to?

@u-pr
Copy link
Contributor

u-pr bot commented Mar 6, 2026

I've analyzed the comments and compared them with the current state of the PR. While many points have been addressed, there are several items that appear to be pending a reaction or implementation:

🛠️ Code Cleanup & Quality

  • Formatter Run: @ekcoh suggested a formatter run might be necessary to clean up minor style inconsistencies (e.g., in InputTestStateManager.cs).
  • Unused Import in InputManager.cs: The using UnityEngine.Tilemaps; import (line 25) was flagged as unrelated and unused. Reference thread.
  • Commented Code in TouchSimulation.cs: The commented-out block in UpdateTouch (line 318) is still present. You previously mentioned it should be removed. Reference thread.
  • Dead Field in Touchscreen.cs: The private static TouchscreenSettings s_Settings; field appears to be unused, as the system now uses the settings property. Reference thread.

🏗️ Refactoring & Consistency

  • PlayerInput.cs Initialization: One of the Instantiate overloads (starting at line 1249) is missing the explicit reset of s_GlobalState.initPairWithDevicesCount = 0;, which was added to the other overload. Reference thread.
  • Grouping Statics in SteamSupport.cs: There was a suggestion to group the Steam-related statics into a single object/struct for consistency with other consolidated states. Reference thread.
  • Location of DeferBindingResolutionContext: A nit was raised about moving this class from InputActionRebindingExtensions.cs to InputManager or its own file. Reference thread.

❓ Pending Clarifications

  • Touch.cs Scene Load Logic: @ekcoh asked for clarification on why s_GlobalState reinitializes between scene loads via BeforeSceneLoad. Reference thread.

✅ Resolved Items

For context, the following were verified as addressed:

  • Memory leak in PlayerInput.DoInstantiate array clearing.
  • Lazy instantiation issues in InputSystemStateManager.OnBeforeSerialize (now uses backing fields).
  • Inline initialization of s_GlobalState in Touch.cs.
  • Various bot suggestions regarding s_PluginsInitialized and Touchscreen.current (verified as false positives or handled implicitly).

🤖 Helpful? 👍/👎

Copy link
Collaborator

@ekcoh ekcoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went through this again and it looks very good @K-Tone! Excellent job. I noticed @MorganHoarau had a few comments that remain open and I had a previous comment which I left unresolved on why we didn't address the multiple statics in Steam support.

Also ran some samples again with domain reloads disabled but didn't run into any problems.

See no need to block this PR so I'll approve now.

/// The s_ConnectedControllers array is allocated in response to setting event handlers and
/// so it can double as our "is installed" flag.
/// </remarks>
private static bool updateHooksInstalled => s_ConnectedControllers != null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this wasn't acted upon? Any reason why?

@ritamerkl ritamerkl removed their request for review March 6, 2026 12:49
Copy link
Collaborator

@jfreire-unity jfreire-unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to block this PR and since so many people have tested it, I'm confident it works. I only raised a question to see if I understand the intent of the change vs the original branch.

Great work @K-Tone , it's great to have this finally in the package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants